//
//  GoodsGridCell.swift
//  WangPu
//
//  Created by xiaozhi on 15/10/13.
//  Copyright (c) 2015年 zhixiao. All rights reserved.
//

import UIKit

class GoodsGridCell: UITableViewCell {
    @IBOutlet var cell1:UIView!
    @IBOutlet var cell2:UIView!
    @IBOutlet var imageView1:XZImageView!
    @IBOutlet var name1:UILabel!
    @IBOutlet var price1:UILabel!
    @IBOutlet var line1:DotView!
    @IBOutlet var btn1:UIButton!
    
    @IBOutlet var imageView2:XZImageView!
    @IBOutlet var name2:UILabel!
    @IBOutlet var price2:UILabel!
    @IBOutlet var line2:DotView!
    @IBOutlet var btn2:UIButton!
    
    @IBOutlet var line1Height:NSLayoutConstraint!
    @IBOutlet var line2Height:NSLayoutConstraint!
    var indexPath:NSIndexPath?
    var btnHandle:((NSIndexPath?,NSInteger)->Void)?
    @IBAction func btn1Click(button:UIButton)->Void{
        if let path = indexPath{
            btnHandle?(path,0)
        }
    }
    @IBAction func btn2Click(button:UIButton)->Void{
        if let path = indexPath{
            btnHandle?(path,1)
        }
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        self.selectionStyle = UITableViewCellSelectionStyle.None
        contentView.backgroundColor = UIColor(red: 239/255.0, green: 239/255.0, blue: 239/255.0, alpha: 1.0)
        cell1.layer.cornerRadius = 3.0
        cell2.layer.cornerRadius = 3.0
        price1.textColor = commonRedColor
        price2.textColor = commonRedColor
        let delaytime:NSTimeInterval = 0.02
        let dipatchTime:dispatch_time_t = dispatch_time(DISPATCH_TIME_NOW, Int64(delaytime*Double(NSEC_PER_SEC)))
        dispatch_after(dipatchTime, dispatch_get_main_queue()){ [weak self] in
            self?.addStroke()
        }
    }
    func addstrokeDelay(){
        let delaytime:NSTimeInterval = 0.02
        let dipatchTime:dispatch_time_t = dispatch_time(DISPATCH_TIME_NOW, Int64(delaytime*Double(NSEC_PER_SEC)))
        dispatch_after(dipatchTime, dispatch_get_main_queue()){ [weak self] in
            self?.addStroke()
        }
    }
    func addStroke(){
        line1.storkeDot()
        line2.storkeDot()
    }
//    override func layoutIfNeeded() {
//        super.layoutIfNeeded()
//        line1.storkeDot()
//        line2.storkeDot()
//    }
    override func prepareForReuse() {
        super.prepareForReuse()
        cell2.hidden = false
    }
    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
